{% extends "layout.html" %}

{% block title %}Gestion des clients{% endblock %}

{% block content %}
<!-- script pour modif odre affichage -->
<script type="text/javascript"> if (window.jQuery == undefined) document.write( unescape('%3Cscript src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"%3E%3C/script%3E') );</script>
<script type="text/javascript" src="js/vendor/jquery.tablesorter.min.js"></script>
<script>
	$(function(){
  $("#myTable").tablesorter();
});
</script>
<!-- Formulaire de recherche -->
<form method="get">
<fieldset>
{% if not(session.niveauAuth=='9')%}
		<legend>Recherche d'un client</legend>
  
		<div class="input-prepend">
			<span class="add-on"><i class="icon-user"></i></span>
            <input name="search-id" id="search-id" type="text" placeholder="N° compte client" class="input-medium" value="{{searchId}}"/> 
        </div>
            
        <div class="input-prepend">
			<span class="add-on"><i class="icon-user"></i></span>
			<input name="search-name" id="search-name" type="text" placeholder="Nom ou Raison Sociale" value="{{searchName}}"/>
        </div>
       
        <div class="input-prepend">
			<span class="add-on"><i class="icon-signal"></i></span>
			<input name="search-numero" id="search-numero" type="text" placeholder="N° de ligne" value="{{searchNumero}}"/> 
        </div>
       
        <div class="input-prepend">
			<span class="add-on"><i class="icon-signal"></i></span>
			<input name="search-sim" id="search-sim" type="text" placeholder="N° carte sim" value="{{searchSim}}"/>
        </div>
		
        <div class="input-prepend">
			<button type="submit" class="btn btn-info" name="action" value="search"><i class="icon-search icon-white"></i> Rechercher</button>
		</div>
</fieldset>
</form>

<!-- Bouton de création de client -->
<fieldset>
		<legend>Creation rapide</legend>
  
            <a href="creation-compte-client" class="btn btn btn-primary"><i class="icon-plus-sign icon-white"></i> Créer un nouveau client </a>
  			
{% endif %}
</fieldset>			

<!-- Tableau listant les clients -->
<fieldset>
		<legend>Liste des clients</legend>
		<table class="table table-striped tablesorter" id="myTable" >
		  <thead>
			<tr>
			  <th>Compte client</th>
			  <th>Nom Prénom</th>
			  <th>Raison sociale</th>
			  <th></th>
			</tr>
		  </thead>
		  <tbody>
			{% for client in clients %}
			<tr>
				<td>{{client.code_client_hto}}</td>
				<td>{{client.nom}} {{client.prenom}}</td>
				<td>{{client.raison_social}}</td>
				<td>
					<div class="btn-group">
					  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						Actions
						<span class="caret"></span>
					  </a>
					  <ul class="dropdown-menu">
					  {% if not(session.niveauAuth=='9')%}
							<li><a href="detail-client?id={{client.code_client_hto}}"><i class="icon-edit"></i> Modification</a></li>
							<li><a href="majloginpassword?id={{client.code_client_hto}}"><i class="icon-edit"></i> MAJ Login password</a></li>
							<li><a href="liste-client?action=delete&id={{client.code_client_hto}}"><i class="icon-trash"></i> Suppression</a></li>
							{% endif %}
							<li class="divider"></li>
							{% if not(session.niveauAuth=='2' or session.niveauAuth=='5' or session.niveauAuth=='6'or session.niveauAuth=='9') %}
                            <li><a href="detail-offre-client-fixe?id={{client.code_client_hto}}"><i class="icon-eye-open"></i> Détail offre fixe</a></li>
							 <li><a href="detail-offre-client-internet?id={{client.code_client_hto}}"><i class="icon-eye-open"></i> Détail offre internet</a></li>
							 {% endif %}
							 {% if (session.niveauAuth=='1')or(session.niveauAuth=='5')or(session.niveauAuth=='2')or(session.niveauAuth=='4')or(session.niveauAuth=='6')or(session.niveauAuth=='9') %}
                              <li><a href="detail-offre-client-mobile?id={{client.code_client_hto}}"><i class="icon-eye-open"></i> Détail parc mobile</a></li>
                                                           
							{% endif %}
							<li class="divider"></li>
							<li><a href="liste-commande?code_client_hto={{client.code_client_hto}}"><i class="icon-th-list"></i> Lister les commandes</a></li>
							<li><a href="creation-commande?code_client_hto={{client.code_client_hto}}&action=creation-commande"><i class="icon-shopping-cart"></i> Créer une commande </a></li>
							<li><a href="creation-facture-ponctuelle?code_client_hto={{client.code_client_hto}}"><i class="icon-edit"></i> Créer une facturation ponctuelle </a></li>
					  		<li class="divider"></li>
					  		{% if (session.niveauAuth=='1')or(session.niveauAuth=='5')or(session.niveauAuth=='6')or(session.niveauAuth=='8') %}
                            <li><a href="cdr-extraction?action=detail&code_client_hto={{client.code_client_hto}}"><i class="icon-edit"></i> Télécharger le CDR Mobile </a></li>
					  		{% endif %}
					  </ul>
					</div>
				</td>
			</tr>
			{% endfor %}
		  </tbody>
		</table>
</fieldset>
    
{% endblock %}
	
